﻿using UnityEngine;
using System.Collections;

namespace NetWork.Sockets.Event.Msg
{
	public class MsgPacket
	{	
		
		public MsgPacket(int nOpcode, bool bBlock , DelegateFunc dFunc, int nSceneId)
		{
			m_nOpcode = nOpcode;
			m_bBlock = bBlock;
			m_dFunc = dFunc;
			m_nSceneId = nSceneId;
		}
		
		public int m_nOpcode{get;private set;}
		public bool m_bBlock{get;private set;}
		public DelegateFunc m_dFunc{get;private set;}
		public int m_nSceneId{get;private set;}
		
		public bool CallDelegateFunc (object msg)
		{
			if (m_dFunc == null)
			{
				Debug.Log("CallDelegateFunc error : no delegate function!");
				return false;
			}
			if (m_bBlock)
			{
				m_dFunc(msg);
			} else{
				m_dFunc(msg);
			}
			return true;
		}
			
	}
	public delegate void DelegateFunc(object msg);
}